<template>
  <el-dialog
    :visible="showDialog"
    top="10vh"
    :show-close="false"
    @close="handleClose"
  >
    <template #title>
      <div style="background: orange">
        <h2 style="text-align: center">
          😏🥶🤬🤢🥸👿👻👽👾🤖💩😾🙈🦓🐴🦄🐔🌭🍟🥨🥯🥖🧑‍🎄🎅
        </h2>
        <h2 style="text-align: center">修改标签</h2>
      </div>
    </template>
    <!-- 表单区域 -->
    <el-form label-width="120px">
      <el-form-item label="所属学科">
        <el-select v-model="disicData.subjectID">
          <el-option
            v-for="item in subjectList"
            :key="item.id"
            :label="item.subjectName"
            :value="item.id"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="标签名称✨">
        <el-input v-model="disicData.directoryName" />
      </el-form-item>
      <el-form-item label="标签">
        <el-input v-model="disicData.tagName" />
      </el-form-item>
    </el-form>
    <template #footer>
      <el-button type="primary" @click="handleClose">取消</el-button>
      <el-button type="primary" @click="handelreset">修改</el-button>
    </template>
  </el-dialog>
</template>

<script>
import { resetTagAPI } from '@/api/disic'
import { getAllSubjectListAPI } from '@/api/subject'
export default {
  name: 'ResetInfoCom',
  props: {
    showDialog: {
      type: Boolean,
      default: false
    },
    disicData: {
      type: Object,
      required: true
    }
  },
  data() {
    return {
      // 学科列表
      subjectList: []
    }
  },
  created() {
    console.log('zhi', this.disicData)
    this.getAllSubjectList()
  },
  methods: {
    // 获取学科列表
    async getAllSubjectList() {
      const resp = await getAllSubjectListAPI()
      // console.log('学科列表', resp)
      this.subjectList = resp.data.items
    },
    // 修改
    async handelreset() {
      try {
        const resp = await resetTagAPI(this.disicData)
        console.log(resp)
        await this.$message.success('修改成功🧠')
        this.handleClose()
      } catch (error) {
        console.log(error)
      }
    },
    // 关闭弹窗
    async handleClose() {
      this.$emit('add-success')
      this.$emit('closeDialog')
    }
  }
}
</script>

<style lang="scss" scoped>
// 设置富文本编辑器的默认最小高度
::v-deep .ql-editor {
  min-height: 300px;
}
</style>
